package com.ehotting.mqbd.zw.api.domain.netty.task;

import com.ehotting.mqbd.zw.api.domain.netty.ZwCommPacket;
import com.ehotting.mqbd.zw.api.domain.protoc.ZwTaskResponse;
import com.google.protobuf.InvalidProtocolBufferException;

/**
 * 单向的，s->c
 */
public class TaskOptBaseReq extends ZwCommPacket {

    protected ZwTaskResponse.ZwTaskOpt zwTaskOpt;

    public TaskOptBaseReq() {
    }

    public TaskOptBaseReq(String actionStr) {
        super(actionStr);
    }

    @Override
    public void convertToHexStr() {
        if (zwTaskOpt !=null) {
            byte[] buff = zwTaskOpt.toByteArray();
            this.setBuff(buff);
        }
    }

    @Override
    public void convertToProp() {
        byte[] buff = this.getBuff();
        int bufSize = this.getHead().getBufSize();
        if (buff==null||bufSize==0){
            return;
        }
        try {
            this.zwTaskOpt = ZwTaskResponse.ZwTaskOpt.parseFrom(buff);
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        TaskOptBaseReq req = new TaskOptBaseReq();
        System.out.println(req.toString());

    }
}
